package org.kl.auditsupervision.entity.fnd;
import java.sql.Timestamp;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;
import org.joda.time.DateTime;
import org.kl.bf.entity.Excel;
import org.kl.bf.entity.ProcessWithAttachEntity;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 *  审计明细
 */
@Entity
@Table(name = "SJJC_AUDIT_DETAILS")
public class AuditProDtl extends ProcessWithAttachEntity {
	private static final long serialVersionUID = 1L;
	    @Excel(exportName = "审计监察法务项目",exportProperty="auditName")
	    private AuditPro  auditPro;
	    @Excel(exportName = "审计监察法务评价")
	    private String auditEvaluation;
	    private String auditEvaluationNo;//审计监察法务评价代码	    
	    @Excel(exportName = "审计监察法务发现问题")
	    private String auditFinding;
	    private String auditFindingNo;//审计监察法务发现问题代码
	    private String auditFindingEva;//发现问题所属评价代码--无用	    
	    @Excel(exportName = "审计监察法务建议")
	    private String auditSuggestion;
	    private String auditSuggestionNo;//审计监察法务建议代码
	    @Excel(exportName = "部门",exportProperty="orgName")
	    private Org org;
	    @Excel(exportName = "责任人",exportProperty="trueName")
		private Employee employee;
	    
	    private Integer status;//各项目整改完成率
	    private Integer planTimes;
	    private Integer resultTimes;
	    @Excel(exportName = "整改计划最迟提交时间", exportConvertSign = 1)
	    private Timestamp zgPlanSubTime;
	    @Excel(exportName = "整改计划实际提交时间", exportConvertSign = 1)
	    private Timestamp zgPlanSubSjTime;
	    @Excel(exportName = "整改结果最迟提交时间（整改计划完成时间）", exportConvertSign = 1)
	    private Timestamp zgResultSubTime;
	    @Excel(exportName = "整改结果实际提交时间", exportConvertSign = 1)
	    private Timestamp zgResultSubSjTime;
	    @Excel(exportName = "内控监督人",exportProperty="trueName")
		private Employee superintendent;
	    private Integer isCxzg;
	    private Integer detailsCnt;
	    @Excel(exportName = "审批状态", exportConvertSign = 1)
		private Integer spxx;
	    @Excel(exportName = "当前操作人")
	    private String currentOperator;
	    private Integer systemCount;
		 
		public AuditProDtl() {
		}

		public AuditProDtl(String id) {
			this.id = id;
		}
		
		@ManyToOne
		@JoinColumn(name = "AUDIT_PRO_ID")
		public AuditPro getAuditPro() {
			return auditPro;
		}

		public void setAuditPro(AuditPro auditPro) {
			this.auditPro = auditPro;
		}

		@ManyToOne
		@JoinColumn(name = "employee_id")
		public Employee getEmployee() {
			return employee;
		}

		public void setEmployee(Employee employee) {
			this.employee = employee;
		}

		@ManyToOne
		@JoinColumn(name = "org_id")
		public Org getOrg() {
			return org;
		}

		public void setOrg(Org org) {
			this.org = org;
		}
		
		
		public String getAuditEvaluation() {
			return auditEvaluation;
		}

		public void setAuditEvaluation(String auditEvaluation) {
			this.auditEvaluation = auditEvaluation;
		}

		public String getAuditEvaluationNo() {
			return auditEvaluationNo;
		}

		public void setAuditEvaluationNo(String auditEvaluationNo) {
			this.auditEvaluationNo = auditEvaluationNo;
		}

		public String getAuditFinding() {
			return auditFinding;
		}

		public void setAuditFinding(String auditFinding) {
			this.auditFinding = auditFinding;
		}

		public String getAuditFindingNo() {
			return auditFindingNo;
		}

		public void setAuditFindingNo(String auditFindingNo) {
			this.auditFindingNo = auditFindingNo;
		}

		public String getAuditFindingEva() {
			return auditFindingEva;
		}

		public void setAuditFindingEva(String auditFindingEva) {
			this.auditFindingEva = auditFindingEva;
		}

		public String getAuditSuggestion() {
			return auditSuggestion;
		}

		public void setAuditSuggestion(String auditSuggestion) {
			this.auditSuggestion = auditSuggestion;
		}		

		public String getAuditSuggestionNo() {
			return auditSuggestionNo;
		}

		public void setAuditSuggestionNo(String auditSuggestionNo) {
			this.auditSuggestionNo = auditSuggestionNo;
		}

		public Integer getStatus() {
			return status;
		}

		public void setStatus(Integer status) {
			this.status = status;
		}

		public Integer getPlanTimes() {
			return planTimes;
		}

		public void setPlanTimes(Integer planTimes) {
			this.planTimes = planTimes;
		}

		public Integer getResultTimes() {
			return resultTimes;
		}

		public void setResultTimes(Integer resultTimes) {
			this.resultTimes = resultTimes;
		}
		
		@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
		public Timestamp getZgPlanSubTime() {
			return zgPlanSubTime;
		}

		public void setZgPlanSubTime(Timestamp zgPlanSubTime) {
			this.zgPlanSubTime = zgPlanSubTime;
		}

		@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
		public Timestamp getZgPlanSubSjTime() {
			return zgPlanSubSjTime;
		}

		public void setZgPlanSubSjTime(Timestamp zgPlanSubSjTime) {
			this.zgPlanSubSjTime = zgPlanSubSjTime;
		}

		@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
		public Timestamp getZgResultSubTime() {
			return zgResultSubTime;
		}

		public void setZgResultSubTime(Timestamp zgResultSubTime) {
			this.zgResultSubTime = zgResultSubTime;
		}

		@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
		public Timestamp getZgResultSubSjTime() {
			return zgResultSubSjTime;
		}

		public void setZgResultSubSjTime(Timestamp zgResultSubSjTime) {
			this.zgResultSubSjTime = zgResultSubSjTime;
		}

		@ManyToOne
		@JoinColumn(name = "superintendent_id")
		public Employee getSuperintendent() {
			return superintendent;
		}

		public void setSuperintendent(Employee superintendent) {
			this.superintendent = superintendent;
		}

		public Integer getIsCxzg() {
			return isCxzg;
		}

		public void setIsCxzg(Integer isCxzg) {
			this.isCxzg = isCxzg;
		}
		
		@Formula("(select count(*) from SJJC_zgcs z where z.audit_pro_dtl_id= id)")
		public Integer getDetailsCnt() {
			return detailsCnt;
		}

		public void setDetailsCnt(Integer detailsCnt) {
			this.detailsCnt = detailsCnt;
		}
		
		@Formula("(select u.true_name from  ACT_HI_ACTINST a,basic_user u  where a.assignee_=u.id and a.proc_inst_id_=process_Instance_Id and a.end_time_ is null)")
		public String getCurrentOperator() {
			return currentOperator;
		}

		public void setCurrentOperator(String currentOperator) {
			this.currentOperator = currentOperator;
		}

		@Override
		public String businessCode() {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public String levelType1() {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public String levelType2() {
			// TODO Auto-generated method stub
			return null;
		}
		
		/**
		 * Excel导出值转换
		 * 
		 * @return
		 */
		public String spxxConvert() {
			return confirmFlag==1?"已通过":(confirmFlag==2?"审批中":(confirmFlag==-1?"已取消":"草稿"));
		}
		
		public String zgPlanSubTimeConvert() {
			return zgPlanSubTime==null?"":new DateTime(zgPlanSubTime).toString("yyyy-MM-dd");
		}
		
		public String zgPlanSubSjTimeConvert() {
			return zgPlanSubSjTime==null?"":new DateTime(zgPlanSubSjTime).toString("yyyy-MM-dd");
		}
		
		public String zgResultSubTimeConvert() {
			return zgResultSubTime==null?"":new DateTime(zgResultSubTime).toString("yyyy-MM-dd");
		}
		
		public String zgResultSubSjTimeConvert() {
			return zgResultSubSjTime==null?"":new DateTime(zgResultSubSjTime).toString("yyyy-MM-dd");
		}

		@Transient
		public Integer getSpxx() {
			return spxx;
		}

		public void setSpxx(Integer spxx) {
			this.spxx = spxx;
		}

		@Formula("(select sum(z.system_count) from sjjc_effect_evaluate z where z.audit_dtl_id= id)")
		public Integer getSystemCount() {
			return systemCount;
		}

		public void setSystemCount(Integer systemCount) {
			this.systemCount = systemCount;
		}
		
		
}

